<?php

namespace User\View\Helper;

use Zend\View\Helper\AbstractHelper;
use Zend\Authentication\AuthenticationService;

class UserIdentity extends AbstractHelper {
	/**
	 * @var AuthenticationService
	 */
	protected $authService;

	/**
	 * @return UserInterface
	 */
	public function __invoke() {
		if($this->getAuthService()->hasIdentity()) {
			return $this->getAuthService()->getIdentity();
		} else {
			return false;
		}
	}

	/**
	 * @return AuthenticationService
	 */
	public function getAuthService() {
		return $this->authService;
	}

	/**
	 * @param AuthenticationService $authService
	 * @return UserIdentity
	 */
	public function setAuthService(AuthenticationService $authService) {
		$this->authService = $authService;
		return $this;
	}
}